<#--
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
-->
<#assign sj=JspTaglibs["/WEB-INF/struts-jquery-tags.tld"]>
<@sj.dialog
    	id="${parameters.id?html}_error_msg"
    	autoOpen="false"
    	modal="false"
    	title="以下のエラーが発生しています。"
    	width="460"
    	position="['right','bottom']"
    	cssStyle="padding:8px;margin: 0;"
    >
<div id="${parameters.id?html}_error_infos">
  <#--	============begin=========	-->
  <#if fieldErrors?if_exists != ""><#t/>
    <#assign eKeys = fieldErrors.keySet()><#t/>
    <#assign eKeysSize = eKeys.size()><#t/>
    <#assign doneStartUlTag=false><#t/>
    <#assign doneEndUlTag=false><#t/>
    <#assign haveMatchedErrorField=false><#t/>
    <#if (fieldErrorFieldNames?size > 0) ><#t/>
        <#list fieldErrorFieldNames as fieldErrorFieldName><#t/>
            <#list eKeys as eKey><#t/>
                <#if (eKey = fieldErrorFieldName)><#t/>
                    <#assign haveMatchedErrorField=true><#t/>
                    <#assign eValue = fieldErrors[fieldErrorFieldName]><#t/>
                    <#if (haveMatchedErrorField && (!doneStartUlTag))><#t/>
                        <#assign doneStartUlTag=true><#t/>
                    </#if><#t/>
					<div
					<#if parameters.id?if_exists != "">
					 id="${parameters.id?html}"<#rt/>
					</#if>
					<#if parameters.cssClass?if_exists != "">
					 class="ui-widget ${parameters.cssClass?html}"<#rt/>
					<#else>
					 class="ui-widget actionError"<#rt/>
					</#if>
					<#if parameters.cssStyle?if_exists != "">
					 style="margin${parameters.cssStyle?html}"<#rt/>
					</#if>
					>
					<div class="ui-state-error ui-corner-all" style="padding: 0.3em 0.7em; margin-top: 20px;">
		                    <#list eValue as eEachValue><#t/>
					            <#if eEachValue?if_exists != "">
							<p id="errorinfo_p_ eValue"><span class="ui-icon ui-icon-alert" style="float: left; margin-right: 0.3em;"></span>
							<span><#if parameters.escape>${eEachValue?html}<#else></#if></span></p>
					            </#if>
							</#list>
					</div>
        			</div>
                </#if><#t/>
            </#list><#t/>
        </#list><#t/>
        <#if (haveMatchedErrorField && (!doneEndUlTag))><#t/>
            <#assign doneEndUlTag=true><#t/>
        </#if><#t/>
        <#else><#t/>
        <#if (eKeysSize > 0)><#t/>
					<div
					<#if parameters.id?if_exists != "">
					 id="${parameters.id?html}"<#rt/>
					</#if>
					<#if parameters.cssClass?if_exists != "">
					 class="ui-widget ${parameters.cssClass?html}"<#rt/>
					<#else>
					 class="ui-widget actionError"<#rt/>
					</#if>
					<#if parameters.cssStyle?if_exists != "">
					 style="margin${parameters.cssStyle?html}"<#rt/>
					</#if>
					>
					<div class="ui-state-error ui-corner-all" style="padding: 0.1em 0.4em; margin-top: 14px;">
            <#list eKeys as eKey><#t/>
                <#assign eValue = fieldErrors[eKey]><#t/>
		                    <#list eValue as eEachValue><#t/>
					            <#if eEachValue?if_exists != "">
							<p id="errorinfo_p_${eKey?html?replace('.', '_' )}" style=" width:420px;margin: 5px 0; padding:0;"><span class="ui-icon ui-icon-alert" style="float: left; margin-right: 0.3em; padding:0;"></span>
							<span ><#if parameters.escape>${eEachValue?html}<#else></#if></span></p>
					            </#if>
							</#list>
            </#list><#t/>
					</div>
        			</div>
        </#if><#t/>
    </#if><#t/>
</#if><#t/>

  <#--	============end===========	-->
</div>
    </@sj.dialog>
    <@sj.a
    	openDialog="${parameters.id?html}_error_msg"
    	onclick="${parameters.id?html}_errorStyle();"
    	id="${parameters.id?html}_open_error_msg"
    	cssStyle="display:none;"
    >
    	Open error_infos dialog
    </@sj.a>

<script language='javascript'>
    function ${parameters.id?html}_errorStyle(){
    	$( '#${parameters.id?html}_error_msg' ).parent().find(".ui-dialog-titlebar").css({ color: "#ff0011", background: "none",border:"none",padding:"0 0 0 8px",margin:"0"});
    }
$(document).ready(function()
{
var focus="";
	if($("#${parameters.id?html}_error_infos").size()>0&&$("#${parameters.id?html}_error_infos").html()!=""){
		$('#${parameters.id?html}_open_error_msg').click();
		var atFocus=0;
		$("#${parameters.id?html}_error_infos p").css({cursor: "pointer"});
			$("#${parameters.id?html}_error_infos p").each(function() {
				var pid=$(this).attr("id");
				$('#'+$(this).attr("id").substring(12)).css({background: "#fecdcd",border:"1px solid #cd0a0a"});
				$('#'+$(this).attr("id").substring(12)+'_mark_temp').css({background: "#fecdcd",border:"1px solid #cd0a0a"});
				$('#'+$(this).attr("id").substring(12)+'_year_temp').css({background: "#fecdcd",border:"1px solid #cd0a0a"});
				$('#'+$(this).attr("id").substring(12)+'_month_temp').css({background: "#fecdcd",border:"1px solid #cd0a0a"});
				$('#'+$(this).attr("id").substring(12)+'_day_temp').css({background: "#fecdcd",border:"1px solid #cd0a0a"});

				if(atFocus==0){
					$('#'+$(this).attr("id").substring(12)).focus();
					atFocus=1;
				}

				$('#'+$(this).attr("id").substring(12)).focus(function(){
					$($("#"+pid)).css({background: "#fe7671",color:"#fff"});
					focus= pid;
		        });

				$('#'+$(this).attr("id").substring(12)).blur(function(){
					$($("#"+pid)).css({background: "none",color:"#cd0a0a"});
				});

				$(this).mouseover(function(){
					$("#error_infos p").css({background: "none"});
					$(this).css({background: "#fe7671",color:"#fff"});
		        });

		        $(this).mouseout(function(){
					$(this).css({background: "none",color:"#cd0a0a"});
				});

		        $(this).click(function(){
		        	$('#'+$(this).attr("id").substring(12)).focus();
		        	if($('#'+$(this).attr("id").substring(12)+'_mark_temp').size()==1){
			        		$('#'+$(this).attr("id").substring(12)+'_mark_temp').focus();
					        }
				});
		        		        	if($('#'+$(this).attr("id").substring(12)+'_mark_temp').size()==1){
		        		$('#'+$(this).attr("id").substring(12)+'_mark_temp').focus(function(){
							$($("#"+pid)).css({background: "#fe7671"});
							focus= pid;
				        });
		        		$('#'+$(this).attr("id").substring(12)+'_mark_temp').blur(function(){
							$($("#"+pid)).css({background: "none"});
						});
		        		$('#'+$(this).attr("id").substring(12)+'_year_temp').focus(function(){
							$($("#"+pid)).css({background: "#fe7671"});
							focus= pid;
				        });
		        		$('#'+$(this).attr("id").substring(12)+'_year_temp').blur(function(){
							$($("#"+pid)).css({background: "none"});
						});
		        		$('#'+$(this).attr("id").substring(12)+'_month_temp').focus(function(){
							$($("#"+pid)).css({background: "#fe7671"});
							focus= pid;
				        });
		        		$('#'+$(this).attr("id").substring(12)+'_month_temp').blur(function(){
							$($("#"+pid)).css({background: "none"});
						});
		        		$('#'+$(this).attr("id").substring(12)+'_day_temp').focus(function(){
							$($("#"+pid)).css({background: "#fe7671"});
							focus= pid;
				        });
		        		$('#'+$(this).attr("id").substring(12)+'_day_temp').blur(function(){
							$($("#"+pid)).css({background: "none"});
						});
				    }
			});
	    }

});
</script>
